import Vue from "vue";
import VueRouter from "vue-router";

import Reg from "@/views/Reg/Reg.vue";
import Login from "@/views/Login/Login.vue";
import Main from "@/views/Main/Main.vue";
import Home from "@/views/Menus/Home/Home.vue";
import User from "@/views/Menus/User/UserInfo.vue";
import UserAvatar from "@/views/Menus/User/UserAvatar.vue";
import UserPwd from "@/views/Menus/User/UserPwd.vue";
import ArtCate from "@/views/Menus/Article/ArtCate.vue";
import Demo from "@/views/Menus/Demo/Demo.vue";




// 把下面的代码粘贴到路由模块中对应的位置，即可防止路由报错的问题

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

Vue.use(VueRouter);

// 配置路由规则
const routes = [
  { path: "/reg", component: Reg },
  { path: "/reg", component: Reg },
  { path: "/login", component: Login },
  {
    path: "/",
    component: Main,
    // 设置重定向
    redirect:'/home',
    children: [
      // 子级路由设置path路径前面不需要加斜杠
      { path: "home", component: Home },
      { path: "user-info", component: User },
      { path: "user-avatar", component: UserAvatar },
      { path: "user-pwd", component: UserPwd },
      { path: "art-cate", component: ArtCate },
      { path: "demo", component: Demo },
     


    

    ],
  },
];

const router = new VueRouter({
  routes,
});

export default router;
